Skip to content
This repository was archived by the owner on Apr 19, 2026. It is now read-only.

Revamp oauth scope handling; support requiring multiple scopes.#147

Merged
inklesspen merged 1 commit intocloudendpoints:masterfrom
inklesspen:scopes
Apr 12, 2018
Merged

Revamp oauth scope handling; support requiring multiple scopes.#147
inklesspen merged 1 commit intocloudendpoints:masterfrom
inklesspen:scopes

Conversation

@inklesspen
Copy link
Copy Markdown
Contributor

This code should properly handle a situation where multiple scopes are necessary for access.

@inklesspen inklesspen requested review from kryzthov and tangiel April 11, 2018 19:22
# pylint: enable=unused-argument


def _process_scopes(scopes):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe document what scopes is?
I believe scopes should be a list of string, and each string is a space-separated list of scope.
Is this correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, whoops!

_logger.debug('Unable to get authorized scopes.', exc_info=True)
return
if not _are_scopes_sufficient(authorized_scopes, sufficient_scopes):
_logger.debug('Authorized scopes did not satisfy scope requirements.')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we return or fail here?

Also, would it be useful to include the actual authorized/sufficient scopes in the log message?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we should. Nice catch.

Honestly, I'm considering removing these lines completely, or attaching them to a separate logger which is normally disabled. These log lines will come up a lot for unauthorized users, so people probably won't want to see them unless they're debugging auth issues.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough

Copy link
Copy Markdown

@kryzthov kryzthov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

_logger.debug('Unable to get authorized scopes.', exc_info=True)
return
if not _are_scopes_sufficient(authorized_scopes, sufficient_scopes):
_logger.debug('Authorized scopes did not satisfy scope requirements.')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough

Comment thread endpoints/users_id_token.py Outdated
return None
os.environ[_ENV_USE_OAUTH_SCOPE] = ' '.join(authorized_scopes)
_logger.debug('Returning user from matched oauth_user.')
return
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this return isn't strictly necessary.

This code should properly handle a situation where multiple scopes are
necessary for access.
@inklesspen inklesspen merged commit 918cd19 into cloudendpoints:master Apr 12, 2018
@inklesspen inklesspen deleted the scopes branch April 12, 2018 23:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants